The purpose of this demo application is to show the flexibility of the Crimson Basic language in terms of interacting with the operating system, and to demonstrate the ease with which a simple form can be displayed and manipulated on the screen.
When an Icon is dragged onto this application, it will display the file type and creator of that file.
This example contains Macintosh Toolbox calls an implements a 'Drag and Drop' application launch capability. Some knowledge of these subjects will be required to fully understand this example.
Double clicking on the FInfo icon will display the Project Window complete with the project related information.
Double clicking on the FinfoForm entry in the Form listbox will display the form for editing.
The rectangle at the top of the form is a Picture type control (double click on this to view its properties). Note that the 'PICT id' property is set to 128 which is the resource id of a PICT resource containing the picture (use ResEdit to view or change this picture).
The Editable Text fields display the file type and creator. Note that the Enabled property is set Off for these controls to ensure that the user can not enter data into these fields.
Initial program module
The GetAppCount() function returns the number of Icons which have been dragged onto the application. If this value is zero, this means that the application was double clicked and an error message is displayed in a modal dialog box using the MsgBox function.
The form FInfoForm is then opened (it is initially invisible because the forms Visible property is set off), the Process_File procedure in the FinfoMain module is called and the form is then made visible using the ShowWindow method.
It may seem strange that the program appears to end at this point but in fact, when the program statements in the 'Initial' module have been processed, the application falls into an 'event processing' mode. At this time, user events are reported to the application and trapped by user written event routines. In this case only one event is trapped (OKButton.Click).
FInfoMain program module
The GetAppMessage() function is called which provides details of how the application was started.
0 (Open File) shows that the application was started by either :
the user dragging an Icon on to the application, or:
the user selected an Icon from the Desktop and selected 'Open' from the Finders'
menu.
1 (Print File) shows that the application was started by the user Selecting and Icon
from the desktop and selecting 'Print' from the Finders' menu.
The GetAppFile() function returns details of each Icon which has been dragged onto the application. These details are returned into a structure named Appstruct which describes the file details of the Icon in question.
The procedure Show_File_Details is called passing file identification parameters.
The values for the File type and Creator are retrieved from the Operating system by use of the _PBGetCatInfo Toolbox call (see the 'Inside Macintosh Files' volume for more details) which returns information about a file into the paramBlock structure.
These values are converted to character format and placed on the form.
The procedure FInfoForm.OKButton.Click is called whenever the OK button is clicked. In this case we simply close the form and End the application.
Note: Implementing the 'Drag and Drop' capability requires the use of a tool such as ResEdit to create resources such as the Bundle resource (BNDL).